<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets">

<ui:composition template="/layout/applicationLayout.xhtml">
	<ui:define name="body">
		<h:form id="form">
			<f:metadata>
				<f:viewParam name="projeto" value="#{lanceBean.projeto}" />

			</f:metadata>
			<p:confirmDialog message="Deseja Contratar Freelancer?"
				appendToBody="true" modal="false" widgetVar="confirmacaoDialog">
				<h:panelGroup id="confirmar">
					<p:commandButton value="Sim" action="#{lanceBean.gerarContrato()}"
						oncomplete="confirmacaoDialog.hide();" />
					<p:commandButton value="Nao" onclick="confirmacaoDialog.hide()" />
				</h:panelGroup>
			</p:confirmDialog>

			<p:confirmDialog message="Registro cadastrado com sucesso"
				widgetVar="fimDialog">

				<p:commandButton value="OK" action="/donoproj/perfilDonoProjeto" />
			</p:confirmDialog>
			<h:inputHidden value="#{lanceBean.projeto}" />
			<div
				style="margin-left: auto; margin-right: auto; width: 60%; height: 7; padding-top: 20px; padding-bottom: 120px;">

				<p:panel header="EFETUAR LANCE">
					<h:panelGrid columns="1">
						<h2>PROJETO: #{lanceBean.projeto.nome}</h2>
						<h2>VALOR: #{lanceBean.projeto.valor}</h2>

					</h:panelGrid>


					<p:dataTable id="grid" var="lance"
						value="#{lanceBean.projeto.lances}">
						
						<p:column headerText="Freelancer">#{lance.freelancer.nome}</p:column>
                                                <p:column headerText="Nacao">#{lance.freelancer.nacao}</p:column>
						<p:column headerText="Localização">#{lance.freelancer.cidade.nome}</p:column>
						<p:column headerText="Valor do Lance" >#{lance.valor}</p:column>
                                                <p:column headerText="Duração" >#{lance.duracao}</p:column>
						
						<p:column headerText="Comentário" >#{lance.comentario}</p:column>
						
						<p:column  headerText="Ação">
							<p:commandButton value="contratar" rendered="#{lance.projeto.aberto}" 
								oncomplete="confirmacaoDialog.show()" update=":form:confirmar">
								<f:setPropertyActionListener value="#{lance}"
							target="#{lanceBean.lanceSelecionado}" />


							</p:commandButton>
						</p:column>
						<f:facet name="footer">
							<p:button value="Voltar" outcome="/donoprojeto/perfilDonoProjeto" />
						</f:facet>
					</p:dataTable>
				</p:panel>
			</div>



		</h:form>


	</ui:define>
</ui:composition>
</html>

